//package com.app.serial.threads;/**
// * @program: app-admin
// * @name MockThread
// * @description: 模拟
// */
//
//import cn.hutool.core.util.RandomUtil;
//import com.app.framework.manager.AsyncManager;
//import com.app.serial.config.SerialConfig;
//import com.app.serial.jsso.JsscComDriver;
//import com.app.serial.jsso.SerialPortListener;
//import com.app.serial.utils.HexByteUtil;
//import com.app.stick.factory.MonitorFactory;
//import jssc.SerialPort;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.math.RoundingMode;
//import java.util.Map;
//
///**
// *@author:
// *@program: app-admin
// *@name MockThread
// *@description: 模拟
// */
//@Slf4j
//@Component
//@EnableScheduling
//@EnableAsync
//public class MockThread {
//
//    /**
//     * 模拟下位机通讯  五秒一次
//     */
//    @Async
//    @Scheduled(cron = "0/5 * * * * ?")
//    public void checkSerial(){
////        String portName = "COM9";
////        Integer baudRate = SerialConfig.getBaudRate();
////        Map<String, SerialPort> serialPortMap = JsscComDriver.serialPortMap;
////        if (!serialPortMap.containsKey(portName)) {
////            JsscComDriver.openSerialPort(portName, baudRate, SerialPortListener.class);
////        }
//
//        //随机生成温度
//        int temperatureBefore = RandomUtil.randomInt(10, 50);
//        String hexTemperatureBefore = HexByteUtil.intToHex(temperatureBefore);
//        int temperatureAfter = RandomUtil.randomInt(1, 9);
//        String hexTemperatureAfter = HexByteUtil.intToHex(temperatureAfter);
//
//        int electricity = RandomUtil.randomInt(1, 100);
//        String hexElectricity = HexByteUtil.intToHex(electricity);
//
//        String command = "A50309" + hexTemperatureAfter + hexTemperatureBefore + "23E5FFA27953" + hexElectricity + "AA";
////        JsscComDriver.sendMessage("COM9", command);
//
//        AsyncManager.me().nowExecute(MonitorFactory.monitor(command));
//    }
//}
